package com.androidx.p013lv.base.utils;

import android.util.Log;

/* renamed from: com.androidx.lv.base.utils.ImageCryptUtils */
public class ImageCryptUtils {
    static byte[] GIF = {71, 73, 70};
    static byte[] JPG = {-1, -40, -1};
    static byte[] PNG = {-119, 80, 78, 71, 13, 10, 26, 10};

    public static byte[] xorEncode(byte[] bArr, int i, String str) {
        if (isDontNeedDecodeForPng(bArr)) {
            Log.e("解密--->", "---->png");
            return bArr;
        } else if (isDontNeedDecodeForGif(bArr)) {
            Log.e("解密--->", "---->gif");
            return bArr;
        } else if (isDontNeedDecodeForJpg(bArr)) {
            Log.e("解密--->", "---->jpg");
            return bArr;
        } else {
            byte[] bArr2 = new byte[bArr.length];
            byte[] bytes = str.getBytes();
            for (int i2 = 0; i2 < i; i2++) {
                bArr2[i2] = (byte) (bArr[i2] ^ bytes[i2 % bytes.length]);
            }
            return bArr2;
        }
    }

    private static boolean isDontNeedDecodeForPng(byte[] bArr) {
        if (bArr.length <= 7) {
            return false;
        }
        byte[] bArr2 = PNG;
        if (bArr2[1] == bArr[1] && bArr2[2] == bArr[2] && bArr2[3] == bArr[3] && bArr2[4] == bArr[4] && bArr2[5] == bArr[5] && bArr2[6] == bArr[6] && bArr2[7] == bArr[7]) {
            return true;
        }
        return false;
    }

    private static boolean isDontNeedDecodeForJpg(byte[] bArr) {
        if (bArr.length <= 7) {
            return false;
        }
        byte[] bArr2 = JPG;
        if (bArr2[0] == bArr[0] && bArr2[1] == bArr[1] && bArr2[2] == bArr[2]) {
            return true;
        }
        return false;
    }

    private static boolean isDontNeedDecodeForGif(byte[] bArr) {
        if (bArr.length <= 2) {
            return false;
        }
        byte[] bArr2 = GIF;
        if (bArr2[0] == bArr[0] && bArr2[1] == bArr[1] && bArr2[2] == bArr[2]) {
            return true;
        }
        return false;
    }
}
